import axios from 'axios'

const request = axios.create({
  baseURL: '/dd',
  headers: {
    'content-type': 'application/x-www-form-urlencoded'
  },
  timeout: 6000
})

// 拦截器
request.interceptors.request.use(
  (config) => {
    config.headers.token =localStorage.getItem('user-token')
    return config
  },
  (error) => Promise.reject(error)
)

request.interceptors.response.use(
  (response) => {
    return response.data
  },
  (error) => Promise.reject(error)
)

export const get = (url = '', params = {})=> {
  return request.get(url, { params })
}

export const post = (url = '', data = {})=> {
  return request.post(url, data)
}
